package com.hr.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hr.entity.AoaRole;
import com.hr.mapper.AoaRoleMapper;
import com.hr.service.AoaRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

/**
 * (AoaRole)表服务实现类
 *
 * @author makejava
 * @since 2022-06-16 20:09:17
 */
@Service("aoaRoleService")
public class AoaRoleServiceImpl extends ServiceImpl<AoaRoleMapper, AoaRole> implements AoaRoleService {
    @Autowired
    private AoaRoleMapper aoaRoleMapper;

    /**
     * 查询角色列表
     * @return
     */
    @Override
    public Page<AoaRole> queryList(Page<AoaRole> page, String roleName) {
        page=aoaRoleMapper.queryList(page,roleName);
        return page;
    }

    /**
     * 保存或修改
     * @param aoaRole
     * @return
     */
    @Override
    public boolean save(@RequestBody AoaRole aoaRole) {
        int row=0;
        if(aoaRole.getRoleId()==null){
            row=aoaRoleMapper.insert(aoaRole);
        }else {
            row=aoaRoleMapper.updateById(aoaRole);
        }
        return row>0;
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @Override
    public boolean delete(Integer id) {
        return aoaRoleMapper.deleteById(id) > 0;
    }

    /**
     * 单值查询
     * @param id
     * @return
     */
    @Override
    public AoaRole queryById(Integer id) {
        return aoaRoleMapper.selectById(id);
    }
}

